﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace Clmp.Data.DBEntity2
{
    public class StoredProcedureParameter<T> : IStoredProcedureParameter
    {
        public StoredProcedureParameter()
        {
            Direction = ParameterDirection.Input;
        }
        public StoredProcedureParameter(string name)
            : this()
        {
            Name = name;
        }
        public StoredProcedureParameter(string name, T value)
            : this()
        {
            Name = name;
            Value = value;
        }

        public StoredProcedureParameter(string name, T value, ParameterDirection direction)
            : this(name, value)
        {
            Direction = direction;
        }

        public string Name { get; set; }
        public T Value { get; set; }
        public ParameterDirection Direction { get; set; }
        public Type GetValueType()
        {
            return typeof(T);
        }

        #region IStoredProcedureParameter 成员


        object IStoredProcedureParameter.Value
        {
            get
            {
                return Value;
            }
            set
            {
                Value = (T)value;
            }
        }

        #endregion
    }

    public interface IStoredProcedureParameter
    {
        string Name { get; set; }
        object Value { get; set; }
        ParameterDirection Direction { get; set; }
        Type GetValueType();
    }
}
